#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QLineEdit>
#include <QListView>
#include <QStringListModel>
#include <QEvent>
#include <QKeyEvent>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
protected:
    bool eventFilter(QObject *watched, QEvent *event) override;
private slots:
    void onTextChanged(const QString &text);
    void keyPressEvent(QKeyEvent *event) override;
    // bool eventFilter(QObject *watched, QEvent *event) override;
    // bool eventFilter(QObject *watched, QEvent *event) override{
    //     if(watched ==  lineEdit){
    //         if(event->type() == QEvent::KeyPress){
    //             QKeyEvent *keyEvent = static_cast<QKeyEvent*> (event);
    //             if(keyEvent->key() == Qt::Key_Space){

    //             }
    //             return true;
    //         }
    //     }
    //     return QMainWindow::eventFilter(watched, event);
    // }
private:
    // Ui::MainWindow *ui;
    QLineEdit *lineEdit;
    QListView *listView;
    QStringListModel *model;
    QStringList initialItems;
};
#endif // MAINWINDOW_H
